package com.guoxin.thread.createthread;

/**
 * 通过继承Thread类创建线程
 *
 * @author guoxin
 * @date 2019/6/26
 */
public class ThreadDemo {
    private static final int THREAD_PRIORITY_NUM = 5;

    public static void main(String[] args) {
        System.out.println("创建线程开始 main");
        CreateThread thread = new CreateThread();
        thread.setPriority(THREAD_PRIORITY_NUM);
        thread.start();
        System.out.println("线程已启动");
        for (int i = 0; i < 1000; i++) {
            System.out.println(Thread.currentThread().getName() + "---" + i);
        }
    }
}

class CreateThread extends Thread {

    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            System.out.println(Thread.currentThread().getName() + "---" + i);
        }
    }
}